home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / packet / p_aa4re / bb212src / bbauxi.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-01-20  |  6.4 KB  |  167 lines

  1. (*===========================================================================*)
  2. (* Check inactive channels                                                   *)
  3. (*                                                                           *)
  4. (*   Copyright 1988, 1989, 1990, 1991, 1992 by H. Roy Engehausen.  All       *)
  5. (*   rights reserved.                                                        *)
  6. (*                                                                           *)
  7. (*===========================================================================*)
  8.  
  9. PROCEDURE check_inact;
  10.  
  11.   VAR
  12.     clean_now    : BOOLEAN;
  13.     new_tcb      : tcb_ptr;
  14.     test_channel : BYTE;
  15.  
  16.  
  17.   (*=========================================================================*)
  18.   (* Subroutine to check an inactive port                                    *)
  19.   (*=========================================================================*)
  20.  
  21.   PROCEDURE check_inact_subr;
  22.  
  23.     VAR
  24.       cvt_string   : STRING[3];
  25.  
  26.     BEGIN;
  27.  
  28.       WITH active_port^, active_tcb^ DO
  29.         BEGIN;
  30.  
  31.           (*-----------------------------------------------------------------*)
  32.           (* Prep the TCB for polling sequence                               *)
  33.           (*-----------------------------------------------------------------*)
  34.  
  35.           channel        := test_channel;
  36.           port_chan_s[2] := byte_to_char[test_channel];
  37.  
  38.           (*-----------------------------------------------------------------*)
  39.           (* Execute the poll                                                *)
  40.           (*-----------------------------------------------------------------*)
  41.  
  42.           task_switch;
  43.           send_recv_tnc(2);
  44.  
  45.           (*-----------------------------------------------------------------*)
  46.           (* Process positive response.  Verify proper type and start a      *)
  47.           (* new task if we can                                              *)
  48.           (*-----------------------------------------------------------------*)
  49.  
  50.           IF NOT tnc_null THEN
  51.             BEGIN;
  52.  
  53.               t_str := port_chan_s + 'L:';
  54.               window_write(t_str, tnc_data.str_data);
  55.  
  56.               IF tnc_type = t_to_h_links THEN
  57.                 BEGIN;
  58.  
  59.                   new_tcb := task_create(@user_start, user_stack_size);
  60.  
  61.                   IF new_tcb = NIL THEN
  62.                     BEGIN;
  63.                       window_write_critical(t_str,
  64.                                  'Out of tasks for a link status change');
  65.                       cmd_tnc(@disc_cmd, true);
  66.                     END;
  67.  
  68.                   connected^[test_channel] := new_tcb;
  69.  
  70.                 END
  71.               ELSE
  72.                 BEGIN;
  73.  
  74.                   IF tnc_type < SIZEOF(byte_to_char) THEN
  75.                     cvt_string := byte_to_char[tnc_type]
  76.                   ELSE
  77.                     STR(tnc_type, cvt_string);
  78.  
  79.                   window_write_critical(t_str,
  80.                           'DED host mode protocol error on INACT -- '
  81.                                                                  + cvt_string);
  82.  
  83.                 END;
  84.  
  85.             END; (*----- End not null processing ----------------------------*)
  86.  
  87.           (*-----------------------------------------------------------------*)
  88.           (* Reset who we are                                                *)
  89.           (*-----------------------------------------------------------------*)
  90.  
  91.           port_chan_s[2] := '0';
  92.           channel        := 0;
  93.  
  94.         END; (*------- End active port addressing ---------------------------*)
  95.  
  96.     END;
  97.  
  98.   (*=========================================================================*)
  99.   (* Main line                                                               *)
  100.   (*=========================================================================*)
  101.  
  102.   BEGIN;
  103.  
  104.     WITH active_port^, active_tcb^ DO
  105.       BEGIN;
  106.  
  107.         (*-------------------------------------------------------------------*)
  108.         (* Bump the cleanup count and see if it is time                      *)
  109.         (*-------------------------------------------------------------------*)
  110.  
  111.         INC(clean_count);
  112.         clean_now := clean_count > 60;
  113.  
  114.         (*-------------------------------------------------------------------*)
  115.         (* Set channel tester                                                *)
  116.         (*-------------------------------------------------------------------*)
  117.  
  118.         test_channel := 1;
  119.  
  120.         (*-------------------------------------------------------------------*)
  121.         (* Loop thru the channels                                            *)
  122.         (*-------------------------------------------------------------------*)
  123.  
  124.         WHILE (test_channel <= max_chan) DO
  125.           BEGIN;
  126.  
  127.             (*---------------------------------------------------------------*)
  128.             (* If channel not connected, then test it                        *)
  129.             (*---------------------------------------------------------------*)
  130.  
  131.             IF connected^[test_channel] = NIL THEN
  132.               BEGIN;
  133.  
  134.                 (*------------------------------------------------------------*)
  135.                 (* Check the channel                                          *)
  136.                 (*------------------------------------------------------------*)
  137.  
  138.                 check_inact_subr;
  139.  
  140.                 (*------------------------------------------------------------*)
  141.                 (* If not in clean mode, we can leave                         *)
  142.                 (*------------------------------------------------------------*)
  143.  
  144.                 IF NOT clean_now THEN
  145.                   EXIT;
  146.  
  147.               END;
  148.  
  149.             (*---------------------------------------------------------------*)
  150.             (* Bump channel number                                           *)
  151.             (*---------------------------------------------------------------*)
  152.  
  153.             INC(test_channel);
  154.  
  155.           END; (*----- End channel loop -------------------------------------*)
  156.  
  157.         (*-------------------------------------------------------------------*)
  158.         (* Reset clean counter if necessary                                  *)
  159.         (*-------------------------------------------------------------------*)
  160.  
  161.         IF clean_now THEN
  162.           clean_count := 0;
  163.  
  164.       END; (*------- End active port addressing -----------------------------*)
  165.  
  166.   END;
  167.